package com.xique.door.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xique.door.bean.dao.*;
import com.xique.door.bean.domain.BuildHouse;
import com.xique.door.bean.domain.User;
import com.xique.door.bean.request.buildHouse.BuildHouseSearchRequest;
import com.xique.door.bean.request.RentStatisticRequest;
import com.xique.door.bean.search.AreaBuildingHouseSearch;
import com.xique.door.bean.vo.SimpleHouseVo;
import com.xique.door.bean.vo.area.AreaBuildingHouseVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 房屋Mapper接口
 *
 * @author caogq
 * @date 2021-09-09
 */
@Repository
public interface BuildHouseMapper  extends BaseMapper<BuildHouse>
{
    /**
     * 查询房屋
     *
     * @param id 房屋ID
     * @return 房屋
     */
    public BuildHouse selectBuildHouseById(Long id);

    /**
     * 查询房屋
     *
     * @param ids 房屋ID
     * @return 房屋
     */
    List<BuildHouse> selectBuildHouseByIds(List<Long> ids);

    /**
     * 查询房屋列表
     *
     * @param buildHouse 房屋
     * @return 房屋集合
     */
    public List<BuildHouse> selectBuildHouseList(BuildHouse buildHouse);

    /**
     * 根据楼栋ID查询房屋列表
     * @author shd
     * @date 2021/9/13 13:58
     * @param ids
     * @return java.util.List<com.jzy.oms.community.build.bean.domain.BuildHouse>
     */
    List<BuildHouse> selectBuildHouseListByBuildingIds(List<Long> ids);

    /**
     * 新增房屋
     *
     * @param buildHouse 房屋
     * @return 结果
     */
    public int insertBuildHouse(BuildHouse buildHouse);

    /**
     * 新增房屋
     *
     * @param buildHouses 房屋
     * @return 结果
     */
    public int insertBuildHouses(List<BuildHouse> buildHouses);

    /**
     * 修改房屋
     *
     * @param buildHouse 房屋
     * @return 结果
     */
    public int updateBuildHouse(BuildHouse buildHouse);

    /**
     * 删除房屋
     *
     * @param id 房屋ID
     * @return 结果
     */
    public int deleteBuildHouseById(Long id);

    /**
     * 批量删除房屋
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteBuildHouseByIds(String[] ids);

    /**
     * 多表条件查询房屋
     * @param
     * @return
     */
    public List<BuildHouse> selectConditionBuildHouseList(BuildHouseSearchRequest request);

    public int countParkHouseNum(Long parkId);

    public int countParkRentNum(Long parkId);

    public int countParkSingleRentNum(Long parkId);


    /**
     * 租客人数统计
     * @author shd
     * @date 2021/12/23 10:57
     * @param parkId
     * @return java.util.List<com.xique.door.bean.dao.TenantStatisticDAO>
     */
    List<TenantStatisticDAO> selectTenantStatisticByBuilding(@Param("parkId") Long parkId);

    /**
     * 房屋出租统计
     * @author shd
     * @date 2021/12/23 10:58
     * @param parkId
     * @return java.util.List<com.xique.door.bean.dao.HouseStatisticDAO>
     */
    List<HouseStatisticDAO> selectHouseStatisticByBuilding(@Param("parkId") Long parkId);

    /**
     * 出租情况统计
     * @author shd
     * @date 2021/12/23 14:21
     * @param request
     * @return java.util.List<com.xique.door.bean.dao.RentUserStatisticDAO>
     */
    List<RentUserStatisticDAO> selectRentUserStatistic(RentStatisticRequest request);

    /**
     * 出租房屋人员数量统计
     * @author shd
     * @date 2021/12/23 14:22
     * @param houseIds
     * @return java.util.List<com.xique.door.bean.dao.RentHouseUserCountStatisticDAO>
     */
    List<RentHouseUserCountStatisticDAO> selectRentHouseUserCountStatisticByHouse(List<Long> houseIds);

    /**
     * 统计每个楼栋出租数量最多的前三个
     * @author shd
     * @date 2021/12/23 10:58
     * @param parkId
     * @return java.util.List<com.xique.door.bean.dao.HouseStatisticDAO>
     */
    List<HouseStatisticDAO> selectBuildingRentHouseTop3(@Param("parkId") Long parkId);


    /**
     * 统计每个楼栋的房屋数量
     * @author shd
     * @date 2021/12/23 10:58
     * @param parkId
     * @return java.util.List<com.xique.door.bean.dao.HouseStatisticDAO>
     */
    List<HouseStatisticDAO> selectFullHouseStatisticByBuilding(@Param("parkId") Long parkId);

    List<FloorHouseDao> selectFloorHouseList(BuildHouse buildHouse);

    List<BuildHouse> batchSelectHouseByHouseCode(List<String> houseCodes);

    List<SimpleHouseVo> areaBuildingHouseList(BuildHouseSearchRequest request);

    List<AreaBuildingHouseVo> selecAreaBuildingHouseInfoByCondition(AreaBuildingHouseSearch search);

    List<User> selectOwnerByHouseIds(@Param("houseIds") List<Long> houseIds );


}
